import 'package:catguard/language.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../config/config.dart';
import '../../generated/assets.dart';
import '../../utils/edit_focus_util.dart';
import '../../views/common_widget.dart';
import 'change_pwd_logic.dart';

class ChangePwdPage extends StatelessWidget {
  ChangePwdPage({super.key});

  final logic = Get.find<ChangePwdLogic>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      backgroundColor: Config.colorBg,
      body: InkWell(
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
        onTap: () {
          FocusManager.instance.primaryFocus?.unfocus();
        },
        child: Stack(
          children: [
            Column(
              children: [
                //appbar
                CommonWidget.commonAppBar("LanguageMsg.settingChangePwd.tr"),
                //中间
                Container(
                  padding: EdgeInsets.only(top: 20.w, left: 60.w, right: 60.w, bottom: 20.w),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      //输入框1
                      Container(
                        margin: EdgeInsets.only(top: 40.w, bottom: 24.w),
                        alignment: Alignment.centerLeft,
                        child: Text(
                          "LanguageMsg.oldPassword.tr",
                          style: TextStyle(
                            color: Config.colorText1,
                            fontSize: Config.textSizeSubTitle.sp,
                          ),
                        ),
                      ),
                      Obx(
                            () => CommonWidget.commonEditText(
                          logic.isHidePwd1.value,
                              (value) {
                            //获得输入的内容
                            logic.oldPwd.value = value;
                          },
                              () {
                            //输入框被点击了
                            EditFocusUtils.setFocus(logic.focusNode1);
                          },
                              () {
                            //右边图标被点击了
                            logic.isHidePwd1.value = !logic.isHidePwd1.value;
                          },
                          logic.focusNode1,
                          isRightIcon: true,
                          maxLength: 40,
                          contentPaddingV: 35.w,
                          hint: "login_input_pwd_tips".tr,
                          fillColor: Config.colorBg2.withOpacity(0.88),
                          sideColorN: Config.colorBg2,
                          sideColorP: Config.colorMain,
                          keyboardType: TextInputType.text,
                          fontSize: Config.textSizeContent.sp,
                        ),
                      ),

                      //输入框2
                      Container(
                        margin: EdgeInsets.only(top: 40.w, bottom: 24.w),
                        alignment: Alignment.centerLeft,
                        child: Text(
                         " LanguageMsg.newPassword.tr",
                          style: TextStyle(
                            color: Config.colorText1,
                            fontSize: Config.textSizeSubTitle.sp,
                          ),
                        ),
                      ),
                      Obx(
                            () => CommonWidget.commonEditText(
                          logic.isHidePwd2.value,
                              (value) {
                            //获得输入的内容
                            logic.newPwd.value = value;
                          },
                              () {
                            //输入框被点击了
                            EditFocusUtils.setFocus(logic.focusNode2);
                          },
                              () {
                            //右边图标被点击了
                            logic.isHidePwd2.value = !logic.isHidePwd2.value;
                          },
                          logic.focusNode2,
                          isRightIcon: true,
                          contentPaddingV: 35.w,
                          rightIconRight: 25.w,
                          maxLength: 20,
                          hint: "login_input_pwd_tips".tr,
                          fillColor: Config.colorBg2.withOpacity(0.88),
                          sideColorN: Config.colorBg2,
                          sideColorP: Config.colorMain,
                          keyboardType: TextInputType.text,
                          fontSize: Config.textSizeContent.sp,
                        ),
                      ),

                      //输入框3
                      Container(
                        margin: EdgeInsets.only(top: 40.w, bottom: 24.w),
                        alignment: Alignment.centerLeft,
                        child: Text(
                          "LanguageMsg.confirmPassword.tr",
                          style: TextStyle(
                            color: Config.colorText1,
                            fontSize: Config.textSizeSubTitle.sp,
                          ),
                        ),
                      ),
                      Obx(
                            () => CommonWidget.commonEditText(
                          logic.isHidePwd3.value,
                              (value) {
                            //获得输入的内容
                            logic.confirmPwd.value = value;
                          },
                              () {
                            //输入框被点击了
                            EditFocusUtils.setFocus(logic.focusNode3);
                          },
                              () {
                            //右边图标被点击了
                            logic.isHidePwd3.value = !logic.isHidePwd3.value;
                          },
                          logic.focusNode3,
                          isRightIcon: true,
                          contentPaddingV: 35.w,
                          rightIconRight: 25.w,
                          maxLength: 20,
                          hint: "login_input_pwd_tips".tr,
                          fillColor: Config.colorBg2.withOpacity(0.88),
                          sideColorN: Config.colorBg2,
                          sideColorP: Config.colorMain,
                          keyboardType: TextInputType.text,
                          fontSize: Config.textSizeContent.sp,
                        ),
                      ),

                      SizedBox(height: 60.w),
                      //确认按钮
                      GestureDetector(
                        onTap: () {
                          logic.upPwd();
                        },
                        child: Container(
                          margin: EdgeInsets.fromLTRB(0.w, 30.w, 0.w, 0.w),
                          padding: EdgeInsets.symmetric(horizontal: 22.w),
                          height: 98.w,
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(58.w)),
                            gradient: const LinearGradient(
                              begin: Alignment.centerLeft,
                              end: Alignment.centerRight,
                              colors: [Color(0xFFA0FF5C), Color(0xFFC1FB93)],
                            ),
                          ),
                          child: Text(
                            "LanguageMsg.confirmBtn.tr",
                            style: TextStyle(color: Config.colorBg, fontSize: 34.sp),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
